<html>
<head><meta charset="utf-8"><title>2021 roadmap · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html">2021 roadmap</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="222487199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222487199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222487199">(Jan 12 2021 at 20:07)</a>:</h4>
<p>It's time to start building our 2021 roadmap</p>



<a name="222487453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222487453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222487453">(Jan 12 2021 at 20:09)</a>:</h4>
<p>I created <a href="https://github.com/rust-lang/wg-async-foundations/issues/22">rust-lang/wg-async-foundations#22</a> to track this, but would like to keep most discussion here</p>



<a name="222487579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222487579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222487579">(Jan 12 2021 at 20:10)</a>:</h4>
<p>(I do think it would be useful, however, to include a pointer to each item we consider on the issue)</p>



<a name="222488989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222488989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222488989">(Jan 12 2021 at 20:22)</a>:</h4>
<p>The first thing I'd like to put up for discussion is <a href="https://github.com/rust-lang/wg-async-foundations/issues/23">rust-lang/wg-async-foundations#23</a>: AsyncRead, AsyncWrite traits</p>



<a name="222489023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222489023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222489023">(Jan 12 2021 at 20:23)</a>:</h4>
<p>I think there's a pretty clear path we can take to adding these to std this year</p>



<a name="222516030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222516030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222516030">(Jan 13 2021 at 00:32)</a>:</h4>
<p><span class="user-mention" data-user-id="116883">@tmandry</span> (Cheering you on. I look forward to having those traits standardized.)</p>



<a name="222573064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222573064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222573064">(Jan 13 2021 at 12:38)</a>:</h4>
<p>Would std versions of <code>sleep()</code>/<code>sleep_for()</code>/<code>interval()</code> be feasible?</p>



<a name="222588583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222588583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222588583">(Jan 13 2021 at 14:39)</a>:</h4>
<p>How would they be implemented?</p>



<a name="222599495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222599495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222599495">(Jan 13 2021 at 15:41)</a>:</h4>
<p>I'm a big fan of AsyncRead / AsyncWrite getting standardized :)</p>



<a name="222599504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222599504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222599504">(Jan 13 2021 at 15:41)</a>:</h4>
<p>and excited to see this discussion start</p>



<a name="222599648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222599648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222599648">(Jan 13 2021 at 15:42)</a>:</h4>
<p>My personal take is that a combination of: standardize stream, async-read, async-write, and work on polish might be a decent start</p>



<a name="222599664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222599664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222599664">(Jan 13 2021 at 15:42)</a>:</h4>
<p>that's a lot of progress</p>



<a name="222599697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222599697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222599697">(Jan 13 2021 at 15:42)</a>:</h4>
<p>(along with I imagine other smaller things)</p>



<a name="222701438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222701438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222701438">(Jan 14 2021 at 10:41)</a>:</h4>
<p><span class="user-mention silent" data-user-id="243558">Steven Fackler</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/2021.20roadmap/near/222588583">said</a>:</p>
<blockquote>
<p>How would they be implemented?</p>
</blockquote>
<p>Maybe it doesn't make sense and would require some kind of <code>Runtime</code> trait</p>



<a name="222952795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/222952795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#222952795">(Jan 16 2021 at 02:28)</a>:</h4>
<blockquote>
<p>Would std versions of sleep()/sleep_for()/interval() be feasible?</p>
</blockquote>
<p>You can do it, but that requires the std to spin up a timer thread and run that in the background. That would never be as efficient as a timer which is integrated into [local thread] runtime.</p>
<p>We could standardize trait versions of those, but i'm not sure how helpful they are.</p>



<a name="223560732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/223560732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#223560732">(Jan 21 2021 at 19:43)</a>:</h4>
<p><span class="user-mention" data-user-id="211722">@Yoshua Wuyts</span> said on the issue:</p>
<blockquote>
<p>I'd like us to consider <a href="https://github.com/rust-lang/wg-async-foundations/issues/11">#11</a>: thread::block_on. And see <a href="https://github.com/rust-lang/wg-async-foundations/issues/12">#12</a> Stream, and <a href="https://github.com/rust-lang/wg-async-foundations/issues/14">#14</a> yield_safe through to stabilization.</p>
<p>edit: also if @betamos has the bandwidth, I'd love to see his original proposal in <a href="https://github.com/rust-lang/wg-async-foundations/issues/19">#19</a> converted into an RFC.</p>
</blockquote>



<a name="223560784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/223560784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#223560784">(Jan 21 2021 at 19:44)</a>:</h4>
<p>(cc <span class="user-mention" data-user-id="137147">@Didrik Nordstrom</span>)</p>



<a name="223560816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/223560816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#223560816">(Jan 21 2021 at 19:44)</a>:</h4>
<p>Thanks for bringing these up, I think they're all reasonable to put on the roadmap</p>



<a name="223561003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/223561003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#223561003">(Jan 21 2021 at 19:45)</a>:</h4>
<p>also cc <span class="user-mention" data-user-id="204219">@Matthias247</span> who wrote the original <a href="https://github.com/rust-lang/rust/pull/65875"><code>block_on</code> PR</a></p>



<a name="223561298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/223561298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#223561298">(Jan 21 2021 at 19:48)</a>:</h4>
<p>The main thing I am concerned about wrt to that is potentially confusing users that they can use that instead of their executor's version for futures which block on some kind of I/O</p>



<a name="223563219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/223563219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#223563219">(Jan 21 2021 at 20:03)</a>:</h4>
<p>That's a fair concern; perhaps we could address by adding some guidance to the RFC for runtimes which we think may be affected by this</p>



<a name="223563668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/223563668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#223563668">(Jan 21 2021 at 20:07)</a>:</h4>
<p>(I have the beginnings of an RFC for this;  will make sure to incorporate this point -- I'm holding off on sharing this publicly until we've landed <code>Stream</code> to limit the amount of things we have in flight at any given time)</p>



<a name="223573630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/223573630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Didrik Nordstrom <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#223573630">(Jan 21 2021 at 21:34)</a>:</h4>
<p><span class="user-mention" data-user-id="116883">@tmandry</span> <span class="user-mention" data-user-id="211722">@Yoshua Wuyts</span> Yes, I can convert the "blocking" lint to an RFC at this point.</p>



<a name="224107116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/224107116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#224107116">(Jan 26 2021 at 21:35)</a>:</h4>
<p>(cc <span class="user-mention" data-user-id="119031">@Esteban Küber</span> to this topic too)</p>



<a name="224241416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/224241416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#224241416">(Jan 27 2021 at 20:18)</a>:</h4>
<p>Along these lines, I've been starting to think about how we define Rust's "vision for async I/O", going beyond a single year.</p>



<a name="224242371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/224242371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#224242371">(Jan 27 2021 at 20:26)</a>:</h4>
<p>I've been working on an <a href="https://hackmd.io/p6cmRZ9ZRQ-F1tlhGaN9rg">Async Vision Document</a> -- this is very much an experiment, I'd love to get feedback on the contents and/or structure.</p>



<a name="224255720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/224255720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Didrik Nordstrom <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#224255720">(Jan 27 2021 at 22:11)</a>:</h4>
<p>Refreshing to see a materialized vision. Agree with these sentiments.</p>



<a name="224256920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/224256920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Didrik Nordstrom <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#224256920">(Jan 27 2021 at 22:20)</a>:</h4>
<blockquote>
<p>Async is like sync, but with blocking points clearly identified. At the highest level, writing a simple program using asynchronous I/O in Rust should be analogous to writing one that uses synchronous I/O, except that one adds async in front of function declarations and adds .await after each call.</p>
</blockquote>
<p>Totally agree. To me, one of the bigger violations of this principle is the inability to reason about and rely on completion of async functions - there are a few proposals for this.</p>
<blockquote>
<p>Library ecosystem is key. We want to have a strong ecosystem of async crates, utilities, and frameworks. This will require mechanisms to write libraries/utilities/frameworks that are generic and interoperable across runtimes.</p>
</blockquote>
<p>+1, again. We are currently witnessing ecosystem divergence and siloing, affecting not only runtimes but downstream crates and so on. If we look at what we <em>have</em> stabilized so far, (through future and context), it's been an amazing success. Now, synchronization and combinators can be used in any async context - independent of runtime. Making progress in this direction for (in ascending difficulty) spawning tasks, timers,  and I/O is truly important to get closer to this goal.</p>



<a name="224311356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/224311356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#224311356">(Jan 28 2021 at 11:06)</a>:</h4>
<p><span class="user-mention" data-user-id="137147">@Didrik Nordstrom</span> say more about "completion" -- can you please send me examples of the proposals?</p>



<a name="224311605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/224311605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#224311605">(Jan 28 2021 at 11:08)</a>:</h4>
<p>Are you think about things like this <a class="stream-topic" data-stream-id="249502" href="/#narrow/stream/249502-wg-async-foundations.2Fstream-trait-rfc/topic/start.2Fend.20polling">#wg-async-foundations/stream-trait-rfc &gt; start/end polling</a>?</p>



<a name="224379755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/224379755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#224379755">(Jan 28 2021 at 19:27)</a>:</h4>
<p>I think he's referring to this: <a href="#narrow/stream/187312-wg-async-foundations/topic/run.20to.20completion.20async.20fn">https://rust-lang.zulipchat.com/#narrow/stream/187312-wg-async-foundations/topic/run.20to.20completion.20async.20fn</a></p>



<a name="224392857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/224392857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Didrik Nordstrom <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#224392857">(Jan 28 2021 at 21:08)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Yes that thread has more context. Conretely: (1) <a href="https://github.com/Matthias247/rfcs/pull/1">https://github.com/Matthias247/rfcs/pull/1</a> and (2) <a href="https://internals.rust-lang.org/t/pre-rfc-leave-auto-trait-for-reliable-destruction/13825">https://internals.rust-lang.org/t/pre-rfc-leave-auto-trait-for-reliable-destruction/13825</a> (async agnostic approach - WIP)</p>



<a name="224393142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/224393142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Didrik Nordstrom <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#224393142">(Jan 28 2021 at 21:10)</a>:</h4>
<p>There's overlap between "async drop", "scoped tasks" and "completion futures" (even cancellation propagation is related) in both problem and solution space. It's a little messy. I had plans to start a collaborative summary doc once the proposals have been thoroughly discussed, and ideally prototyped.</p>



<a name="224393389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/224393389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Didrik Nordstrom <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#224393389">(Jan 28 2021 at 21:12)</a>:</h4>
<p>I have my neutral hat available for any questions about the current state of things. <span class="user-mention" data-user-id="204219">@Matthias247</span> too I'm sure..</p>



<a name="224417695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/224417695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#224417695">(Jan 29 2021 at 00:51)</a>:</h4>
<p><span class="user-mention" data-user-id="137147">@Didrik Nordstrom</span> btw, since you revised the proposal significantly you might consider starting a new thread incorporating everything you learned; long threads tend to be pretty intimidating</p>



<a name="224419861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/224419861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Didrik Nordstrom <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#224419861">(Jan 29 2021 at 01:19)</a>:</h4>
<p>Totally. I have some homework to do first.</p>



<a name="225185752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225185752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225185752">(Feb 04 2021 at 16:36)</a>:</h4>
<p>OK, I've caught up a bit. I have to say that I am pretty skeptical of introducing a new type of asynchronous functions.</p>



<a name="225185859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225185859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225185859">(Feb 04 2021 at 16:37)</a>:</h4>
<p>Introducing async functions at all is a pretty huge cost, in terms of the whole "what color is your function" question, but one that we think/claim is worth its cost, because reasoning about async I/O is worth it etc etc</p>



<a name="225185883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225185883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225185883">(Feb 04 2021 at 16:37)</a>:</h4>
<p>But having <em>two</em> types of such functions? I'd want to be <em>very</em> convinced that we can't address these problems in other ways</p>



<a name="225186026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225186026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225186026">(Feb 04 2021 at 16:38)</a>:</h4>
<p>I do understand that the existing model makes some tradeoffs, embraces one style over another, and that it is not optimal for all things, but I'm not convinced that this is worth the price of trying to introduce a new form of async fn</p>



<a name="225186094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225186094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225186094">(Feb 04 2021 at 16:39)</a>:</h4>
<p>That said, I'm going to print out this RFC and read it in detail :)</p>



<a name="225186106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225186106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225186106">(Feb 04 2021 at 16:39)</a>:</h4>
<p>This is kind of my "off the cuff" reaction</p>



<a name="225206117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225206117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Didrik Nordstrom <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225206117">(Feb 04 2021 at 19:02)</a>:</h4>
<p>I'm on that side too, but I don't want to reject before I've fully understood the proposal and seen the prototype.</p>



<a name="225206178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225206178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Didrik Nordstrom <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225206178">(Feb 04 2021 at 19:02)</a>:</h4>
<p>If/when you read the RFC make sure to check the updated version, it's mentioned at the top. That'll save you time.</p>



<a name="225206911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225206911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Didrik Nordstrom <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225206911">(Feb 04 2021 at 19:07)</a>:</h4>
<p>TL;DR it got broken up into two independent features. <code>Leak</code> enables scoped threads and tasks (static borrowing across tasks/threads which is virtually identical to the proposal from 2015 around the "scoped thread soundness crisis"). <code>ImplicitDrop</code> enables the compiler to enforce that state machines (such as futures) aren't dropped prematurely by accident. They don't depend on each other.</p>



<a name="225215602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225215602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225215602">(Feb 04 2021 at 20:11)</a>:</h4>
<p>It sounds more like Niko is talking about Matthias's RFC</p>



<a name="225215981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225215981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225215981">(Feb 04 2021 at 20:13)</a>:</h4>
<p>I had the same reaction. But I think the design space is worth exploring some until we have an async drop proposal we feel really good about.</p>



<a name="225220451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225220451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ryan Leckey <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225220451">(Feb 04 2021 at 20:50)</a>:</h4>
<p>After hitting the problem this is trying to solve in <em>very large</em> software ( notably SQLx ), I've thought on this for a long time.</p>
<p>I very much agree that we need a third color of functions. However, its not as bad as it sounds I don't think. </p>
<p>For <code>#[completion] async fn</code> I think it would help to frame this as "suspending" functions instead of "asynchronous" functions. We support an asynchronous computation model fairly well but there is a massive amount of library code that is fairly broken (in the face of cancellation, timeouts, web frameworks cancelling requests, etc.) as its built on the preconception that Rust's model is suspension instead of "cooperative asynchronous".</p>
<p>I would even go as far as saying that async functions as they are now should be linted against for having any <code>&amp;mut</code> parameters. The pitfall is way too easy to fall into.</p>
<p>Doing so you start to recommend a world of _pure_ asynchronous computation vs. potentially _impure_ suspending execution.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="c1">// building block</span>
<span class="k">async</span><span class="w"> </span><span class="k">fn</span> <span class="nf">delay</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="cm">/* ... */</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="c1">// outer layer</span>
<span class="n">suspend</span><span class="w"> </span><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="cm">/* ... */</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>I would also recommend to avoid the <code>Future</code> suffix here and call it something like <code>std::task::Deferred&lt;Output&gt;</code>. This helps by framing this as a feature instead of a bolt-on to async.  </p>
<p>If this isn't the right place for this kind of musing, my apologies. New to Zulip here.</p>



<a name="225221551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225221551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Didrik Nordstrom <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225221551">(Feb 04 2021 at 20:59)</a>:</h4>
<p><span class="user-mention" data-user-id="116883">@tmandry</span> Heh, I think you're right. To be clear I was referring to the Pre-RFC posted earlier.</p>



<a name="225222249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225222249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Didrik Nordstrom <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225222249">(Feb 04 2021 at 21:04)</a>:</h4>
<blockquote>
<p>I would even go as far as saying that async functions as they are now should be linted against for having any &amp;mut parameters. The pitfall is way too easy to fall into.</p>
</blockquote>
<p>In the current state, this would make sense. The vision of "async should be analogous to sync" needs some mechanism of preventing against arbitrary interruption..</p>



<a name="225365289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225365289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225365289">(Feb 05 2021 at 22:14)</a>:</h4>
<p>I think linting any <code>&amp;mut</code> parameters would make <code>async fn</code>s pretty much unusable. There's always a socket, timer, etc in it, and interacting with them mutates some state.</p>



<a name="225367413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225367413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225367413">(Feb 05 2021 at 22:36)</a>:</h4>
<p>For the third version of async function: I definitely share the concern of too much functionality and options. However even after multiple years of thinking about it, I can't find another sensible way to cover the scenarios that are supported in other async/await environments.</p>
<p>Rust would be generally safer than e.g. Swift or C++ or Kotlin regarding threading mistakes, but can't support structured concurrency in the same fashion they do. That's not ideal. And not being able to have a true zero-cost abstraction over completion-based IO (which is common in async systems) is also not perfect. </p>
<p>In terms of usage I see things pretty much the same as <span class="user-mention" data-user-id="238574">@Ryan Leckey</span> : Application developers in the future would mostly interact with completion based functions. The regular <code>async fn</code> provides some smaller building blocks - like interacting with channels, timers, synchronization primitives.<br>
I think this is teachable with guidance like "Use the completion based function, unless you wan't your function to be interruptible at any point and are sure it has no negative side effects".</p>
<p>But the "teachable" part is the one where I have the strong preference about a completable function keyword/attribute, instead of a more general <code>Leak</code> one. The first one explains people it's use case, whereas the second one informs them how the desired functionality is achieved. But in order to understand the "how", one needs to have bigger background knowledge,</p>



<a name="225370841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225370841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ryan Leckey <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225370841">(Feb 05 2021 at 23:17)</a>:</h4>
<blockquote>
<p><span class="user-mention silent" data-user-id="204219">Matthias247</span> I think linting any &amp;mut parameters would make async fns pretty much unusable. There's always a socket, timer, etc in it, and interacting with them mutates some state.</p>
</blockquote>
<p>My point with that lint would be to push people to the new completion-based async paradigm. </p>
<p>A timer has mutable state, yes, but not _externally-observable_ mutable state. It's <code>delay(duration).await</code>. </p>
<p>Interacting with a socket/stream within <code>async fn</code> such as <code>async fn foo(stream: &amp;mut TcpStream)</code> is extremely prone to bugs. As an example, in <code>futures-rs</code> the <code>write_all</code> method is very dangerous as you can drop the future for it and you will have no idea how much of the buffer was written to the stream. </p>
<p>There are lots of what I would call async _primitives_ that can be done with a restricted <code>async fn</code> and be consistent.</p>



<a name="225371195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225371195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ryan Leckey <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225371195">(Feb 05 2021 at 23:22)</a>:</h4>
<blockquote>
<p>But the "teachable" part is the one where I have the strong preference about a completable function keyword/attribute,</p>
</blockquote>
<p>Yeah, this is where I'm coming from when I want to call these suspending functions to mirror Kotlin. We want people to type them easily and not be a second choice. </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">suspend</span><span class="w"> </span><span class="k">fn</span> <span class="nf">process</span><span class="p">(</span><span class="n">stream</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">TcpStream</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">i32</span> <span class="p">{</span><span class="w"> </span><span class="o">..</span><span class="p">.</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>With the return type of <code>impl std::task::Deferred&lt;i32&gt;</code>, this now feels like a separate (but complementary) feature from futures and not something tacked on to fix a problem. Especially so with the lint, Rust devs will have guidelines on when to use what kind of method.</p>



<a name="225376248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225376248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225376248">(Feb 06 2021 at 00:32)</a>:</h4>
<p>Some IO primitives are definitely broken when cancelled currently. E.g. everything which buffers internally, or employs some flow control hacks (like all TLS libraries do) is endangered. See e.g. <a href="https://github.com/tokio-rs/tls/issues/41">https://github.com/tokio-rs/tls/issues/41</a></p>
<p>I think most of those should realisitically just close the underyling handle whenever the first operation is aborted - which works with <code>Future</code>s, but not with <code>AsyncRead/Write</code></p>



<a name="225376340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225376340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225376340">(Feb 06 2021 at 00:34)</a>:</h4>
<blockquote>
<p>With the return type of impl std::task::Deferred&lt;i32&gt;, this now feels like a separate (but complementary) feature from futures and not something tacked on to fix a problem.</p>
</blockquote>
<p>Interesting thought. I think we can see it both ways: A different name feels less tackled on. But a similar than indicates that it is not really that much different, and also not fully incompatible. <br>
I'm personally fine with both approaches</p>



<a name="225377358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225377358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ryan Leckey <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225377358">(Feb 06 2021 at 00:54)</a>:</h4>
<blockquote>
<p>I think most of those should realisitically just close the underyling handle whenever the first operation is aborted</p>
</blockquote>
<p>Some of the underlying handles are relatively <strong>expensive</strong> to open. Specifically I'm referring to SQLx. I'm currently rewriting its core to handle the implicit cancellation problem. It's not impossible to do correctly, just requires being _very_ careful. If an operation is dropped (e.g., a query command), what happens now is in the next command, any partially written data finishes being written and packets emitted from that are popped off the stream before we consider any output as relevant. </p>
<hr>
<p>In the RFC you've mentioned that "completion" async functions could not be called from regular async. Technically I don't see that being impossible as long as we have a way to "spawn" in std. It's less efficient for sure, but it could be a nice thing to specify so the function types _can_ be mixed (and mixing like that can always be linted against).</p>



<a name="225384395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/2021%20roadmap/near/225384395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/2021.20roadmap.html#225384395">(Feb 06 2021 at 03:44)</a>:</h4>
<p>Sure, spawning on a long-running runtime and waiting on a handle work. But I don't call this "directly called". It's not efficient, and hasn't the same semantics (the background task can outlive the calling task).</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>